<?php
/**
 * Description of WacBizOrderType
 *    business order type
 *
 * @author ben
 */
class WacBizOrderType
{
    public static $type = array(
        "cotton" => array("name"=>"cotton", "code"=>"1", "label"=>"棉纱单", "orderTableName"=>"WacCottonOrder", "orderItemTableName"=>"WacCottonOrderGoodsItem"),
        "dye" => array("name"=>"dye", "code"=>"2", "label"=>"浆染单", "orderTableName"=>"WacDyeOrder", "orderItemTableName"=>"WacDyeOrderItem"),
        "weave" => array("name"=>"weave", "code"=>"3", "label"=>"织造单", "orderTableName"=>"WacWeaveOrder", "orderItemTableName"=>"WacWeaveOrderItem"),
        "cleanUp" => array("name"=>"cleanUp", "code"=>"4", "label"=>"后整单", "orderTableName"=>"WacCleanUpForm", "orderItemTableName"=>"WacCleanUpFormItem"),
        "finalCloth" => array("name"=>"finalCloth", "code"=>"5", "label"=>"成品单", "orderTableName"=>"WacFinalClothForm", "orderItemTableName"=>"WacFinalClothFormGoodsItem"),
        "dispatchOrder" => array("name"=>"dispatchOrder", "code"=>"6", "label"=>"出货单", "orderTableName"=>"WacDispatchOrder", "orderItemTableName"=>"WacDispatchOrderItem"),
        "cleanUpQc" => array("name"=>"cleanUpQc", "code"=>"7", "label"=>"后整QC单", "orderTableName"=>"WacCleanUpQcForm", "orderItemTableName"=>"WacCleanUpQcFormItem"),
        "finalClothQcTest" => array("name"=>"finalClothQcTest", "code"=>"8", "label"=>"成品布QC测试单", "orderTableName"=>"WacFinalClothQcTestForm", "orderItemTableName"=>"WacFinalClosthQcTestFormItem")
    );

    /*
     * get attribute
     */
    public static function getAttribute($key, $attribute)
    {
        return self::$type[$key][$attribute];
    }

    /*
     * @return attribute by code
     */
    public static function getAttributeByCode($code, $attribute)
    {
        $row = self::getRowByCode($code);
        if($row != false){
            return $row[$attribute];
        }
    }

    /*
     *  getRowById
     * @return false or found array
     */
    public static function getRowByCode($code)
    {
        $result = false;
        foreach(self::$type as $param)
        {
            if($param['code']==$code)
            {
                $result = $param;
                break;
            }
        }
        return $result;
    }

    
}
